﻿@{
    ViewBag.Title = ViewData["SiteName"] + " - " + ViewData["PageTitle"];
    Layout = "~/RazorThemes/Default/Views/Shared/_Layout.cshtml";
}
@section HtmlHead{
}
<div class="contentpage-outerdiv">
    <h2>
        Log On</h2>
    @if (bool.Parse(ViewData["AllowOpenIdRegistration"].ToString()))
    {
        <p>
            Please log in using either <a href="http://openid.net/get-an-openid/" target="_blank">
                OpenID</a> or a UserName and Password or <b>@Html.ActionLink("Register", "Register")</b>
            a new account.
        </p>
    }
    else
    {
        <p>
            Please enter your username and password. @Html.ActionLink("Register", "Register")
            if you don't have an account.
        </p>
    }
    <span class="field-validation-error">&nbsp;@Html.ValidationSummary("Login was unsuccessful.Please correct the errors and try again.") @ViewData["message"] </span>
    <div class="resource-body">@MvcHtmlString.Create(ViewData["resourcebody"].ToString())</div>
    @using (Html.BeginForm("Logon", "Account", FormMethod.Post, new { id = "form1", autocomplete = "off" }))
    {
        <div class="registerContainer">
            <fieldset>
                <legend>Account Information</legend>
                <p>
                    <label for="username">UserName or Email:</label>
                    @Html.TextBox("username", ViewData["OpenId"], new { @class = "required" }) @Html.ValidationMessage("username")
                </p>
                <p>
                    <label for="password">
                        Password:</label>
                    @Html.Password("password", "", new { @class = "required" }) @Html.ValidationMessage("password")
                </p>
                <p>
                    @Html.CheckBox("rememberMe")
                    <label class="inline" for="rememberMe">
                        Remember me?</label>
                </p>
                <p>
                    <input type="submit" value="Log On" />
                </p>
            </fieldset>
        </div>
        @Html.Hidden("returnUrl", ViewData["referer"].ToString())
    }
    @if (string.IsNullOrEmpty(ViewData["OpenId"].ToString()) && bool.Parse(ViewData["AllowOpenIdRegistration"].ToString()))
    {
        using (Html.BeginForm(new { Controller = "Account", Action = "OpenIdLogon" }))
        {
        <div class="registerContainer">
            <fieldset>
                <legend>OpenId Information</legend>
                <div class="containercontent" style="padding: 10px 20px;">
                    <div class="labelheaderblock">
                        Log on using OpenId:</div>
                    <input id="openid_identifier" name="openid_identifier" size="40" />
                    <input id="btnOpenIdLogin" type="submit" value="Login" />
                    <img alt="progress" id="imgOpenIdLoginProgress" src="@Url.Content("~/content/images/loading_small.gif") "
                    style="display: none" />
                    <div id="divOpenIdIcons">
                        <img alt="openid" src="@Url.Content("~/content/images/openid-icon.png") " onclick="openIdUrl('openid')"
                        title="myopenid.com" class="hoverbutton" />
                        <img alt="google" src="@Url.Content("~/content/images/google-icon.png") " onclick="openIdUrl('google')"
                        title="Google" class="hoverbutton" />
                        <img alt="yahoo" src="@Url.Content("~/content/images/yahoo-icon.png") " onclick="openIdUrl('yahoo')"
                        title="Yahoo" class="hoverbutton" />
                    </div>
                </div>
            </fieldset>
            @Html.Hidden("returnUrl", ViewData["referer"].ToString())
        </div>
        }
    }
</div>
@section ScriptContent{
<script src="@Url.Content("/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $("#form1").validate({
        submitHandler: function (form) {
            form.submit();
        }
    });
    $(document).ready(function () {
        $("#btnOpenIdLogin").click(function () {
            $(this).hide();
            $("#imgOpenIdLoginProgress").show();
        });
    });


    function openIdUrl(site) {
        var value = "";
        var autoClick = false;

        if (site == "openid") {
            value = "<Your Account>.myopenid.com"
        }
        else if (site == "google") {
            value = "https://www.google.com/accounts/o8/id";
            autoClick = true;
        }
        else if (site == "yahoo") {
            value = "http://yahoo.com/"
            autoClick = true;
        }

        if (value) {
            var jText = $("#openid_identifier");
            jText.val(value)
            .focus();
            if (autoClick)
                $("#btnOpenIdLogin").trigger("click");
        }

    }	
	
</script>
}
